Getting XQuery [modify()]: Top-level attribute nodes are not supported error while modifying xml
Posted
by sam
on Stack Overflow
See other posts from Stack Overflow
or by sam
Published on 2010-04-09T14:27:10Z
Indexed on
2010/04/09
14:33 UTC
Read the original article
Hit count: 511
DECLARE @mycur CURSOR
DECLARE @id int
DECLARE @ParentNodeName varchar(max)
DECLARE @NodeName varchar(max)
DECLARE @NodeText varchar(max)
SET @mycur = CURSOR
FOR
SELECT * FROM @temp
OPEN @mycur
FETCH NEXT FROM @mycur INTO @id,@ParentNodeName,@NodeName,@NodeText
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @id -- sample statements
PRINT @ParentNodeName
PRINT @NodeName
SET @x.modify
('
insert attribute status {sql:variable("@status")}
as first
into (/@ParentNodeName/@NodeName/child::*[position()=sql:variable("@status")])[1]
')
FETCH NEXT FROM @mycur INTO @id,@ParentNodeName,@NodeName,@NodeText
END
DEALLOCATE @mycur
Any idea why I am getting this error as query works fine if I manually insert path
© Stack Overflow or respective owner